package com.twu.biblioteca;

public class Movie {


    private String name;
    private int year;
    private String director;
    private int rating;

    public Movie(String name, int year, String director) {
        this(name,year,director,0);
    }

    public Movie(String name, int year, String director, int rating) {
        this.name = name;
        this.year = year;
        this.director = director;
        this.rating = rating;
    }


    public String rating() {
        String starredRating= "";
        if(validateRating()){
            starredRating = getStarredRating();
        }else{
            starredRating="N/A";
        }
        return starredRating;
    }

    private String getStarredRating() {
        String starredRating ="";
        for(int i=0; i<rating; i++){
            starredRating+="*";
        }
        return starredRating;
    }

    private boolean validateRating(){
        return rating>0 && rating<=10 ? true:false;
    }



    public String record() {
        return String.format("%s\t\t\t\t%d\t\t%s\t\t\t%s\n",name,year,director, rating());
    }
}
